RoomListView = BaseView:Extend()

function RoomListView:New()
    local o = RoomListView.super.New(self)
    o.abName = "ui_listview"
    o.resName = "RoomListView"
    o.layer = ENUM.UI_LAYER.TOP
    o.item_list = {}
    return o
end

function RoomListView:loadSuccess()
    self.btn_create = GetNode(self.transform,{"btn_create"},"GameObject")
    self.listView = GetNode(self.transform,{"ScrollView"},"_ListView")
    self:InitEvent()

    self.listView:BindItemRender(function (index, widget)
        self.item_list[widget.name] = self.item_list[widget.name] or RoomListItem:New(widget)
        self.item_list[widget.name]:SetData(self.testData[index + 1])
    end)
    
    --房间测试
    self.testData = {}
    -- for i = 1, 10, 1 do
    --     local temp = {
    --         name = "room"..i
    --     }
    --     table.insert(self.testData, temp)
    -- end
    self.listView.itemCount = #self.testData
end

function RoomListView:InitEvent()
    local testIndex = 1
	local click_func = function (target)
		if target == self.btn_create then
			Debug.Log("btn_create 11111")
            local temp = {
                name = "room"..testIndex
            }
            table.insert(self.testData, temp)
            testIndex = testIndex + 1
            self.listView.itemCount = #self.testData
		end
	end
	AddClick(self.btn_create,click_func)
end

function RoomListView:destroy_callback()
end

function RoomListView:__delete()
end